package donot996.icu.controller;


import donot996.icu.service.ICrawlerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@CrossOrigin
@RestController
@RequestMapping("/crawler")
public class CrawlerController {

    @Autowired
    ICrawlerService  crawlerService;
    @GetMapping("/getContent")
    public String getContent(String url){
        String content = null;
        try {
            content = crawlerService.getContent(url);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return content;
    }
}
